package org.teamswift.crow.rbac.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.teamswift.crow.rbac.entity.CrowUserOrganization;
import org.teamswift.crow.rbac.entity.CrowUserRole;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

@Repository
public interface CrowUserOrganizationRepository extends JpaRepository<CrowUserOrganization, Integer>, JpaSpecificationExecutor<CrowUserOrganization> {

    Optional<CrowUserOrganization> findByUserIdAndForeignId(Integer userId, Integer foreignId);

    @Modifying
    void deleteByUserIdAndForeignId(Integer userId, Integer companyId);

    @Modifying
    void deleteByUserIdInAndForeignId(Collection<Integer> userId, Integer companyId);

}
